package homework.Demo1;

import java.util.Comparator;
import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {
        Set<Student> students=new TreeSet<>(new Comparator<Student>() {
            @Override
            public int compare(Student s1, Student s2) {
                return s1.getScore() - s2.getScore();
            }
        });
        Student s1 = new Student(1, "小亮", 99);
        Student s2 = new Student(2, "小勇", 85);
        Student s3 = new Student(3, "小响", 90);
        Student s4 = new Student(4, "小强", 89);
        students.add(s1);
        students.add(s2);
        students.add(s3);
        students.add(s4);
        students.forEach(System.out::println);
    }
}
